package sng.modules.view.components.city.logic.unit
{
	import core.interfaces.IDispose;
	
	import org.casalib.util.ArrayUtil;
	
	import sng.modules.view.components.city.logic.City;
	import sng.utils.BuildingUtil;
	import sng.utils.FilterUtil;
	import sng.utils.IsoUtil;

	/*
	 *装饰建筑奖励加成管理类 royjin 20110715
	*/
	public final class BuildingBonusAddManager
	{
		
		public static  function UpdateBuildingBonus(bd:BaseBuilding):void
		{
			//删除老的
			BuildingBonusAddManager.ResetBuildingBonus(bd);
			
			//显示新的;
			var editBuildingIdList:Array = IsoUtil.getBuildBonusIdArray(bd.column, bd.row, bd.vo.rows, bd.vo.cols);
			//获取建筑中的可以加成的建筑
			for each(var id:int in editBuildingIdList)
			{
				var temp:BaseBuilding = bd.view.getChildByID(id.toString());
				if (temp.vo.buildingTypeId<=BuildingUtil.BUSINESS_TYPE&&temp.skin.filters.length==0)
				{
					temp.skin.filters = [FilterUtil.getGreenFilter()];
					temp.ShowBonusText(bd.vo.bonusRate);
				}
			}
		}
		public static function ResetBuildingBonus(bd:BaseBuilding):void
		{
			//获取建筑中的可以加成的建筑
			for(var i:int=0;i<50;i++)
			{
				for(var j:int=0;j<50;j++)
				{
					var temp:BaseBuilding = bd.view.getChildByID(City.buildingIdArray.get(i, j));
					if (temp!=null&&temp.vo.buildingTypeId<=BuildingUtil.BUSINESS_TYPE)
					{
						if(temp.skin.filters.length>0)
						{
							temp.skin.filters = [];
						}
						temp.HideBonusText();
					}
				}
					
			}
		}	
	}
}